/***********************************************************
 * Author: 	Brandon McKune
 * E-Mail:	bmckune.cs@gmail.com
 * Date:	September 2, 2011
 * Class:	CSc 8370 - Data Security
 * Time:	1150 - 1325
 * Smstr:	Fall 2011
 */

#include "prints.h"
#include "FileHandler.h"
#include "adfgvxDecipher.h"
#include "StatisticsHandler.h"

using namespace std;

int main(int args0, char** args1){
	FileHandler *fh = new FileHandler();
	StatisticsHandler *sh = new StatisticsHandler();
	adfgvxDecipher *ad = new adfgvxDecipher();

	char* fileBuffer = NULL;

	if(!fh->loadFile("data/3boat10.txt")){
		return -1;
	}

	fileBuffer = fh->getBuffer();
	if(fileBuffer == NULL){
		return -1;
	}

	sh->loadCharBuffer(fileBuffer, fh->getBufferSize());
	double psi = sh->getPsi(1);
	printf("psi = %f\n", psi);

	if(!fh->loadFile("data/classcipher")){
		return -1;
	}
	free(fileBuffer);

	fileBuffer = fh->getBuffer();

	if(fileBuffer == NULL){
		return -1;
	}

	ad->loadCipher(fileBuffer, fh->getBufferSize());
	ad->attemptDecription(2, 27);

	ad->printResults();
//
//	MatrixHandler *mh = new MatrixHandler();
//	mh->loadMatrix(fileBuffer, fh->getBufferSize(), 13);

//	char* temp = mh->transposeMatrix();
//	printf("File:\n%s\n", temp);
//	sh->loadCharBuffer(temp, fh->getBufferSize());
//	double temp_d = sh->getPsi(2);
//	printf("Temp: %f\n", temp_d);

	delete(sh);
	delete(fh);
	delete(ad);

	return 0;
}

